import { Component } from '@angular/core';
import {NavController, NavParams } from 'ionic-angular';
import 'rxjs/add/operator/toPromise';
import {HttpServies} from '../../providers/http-servies';
import  {AboutPage} from  '../about/about'
// import { ActionSheetController } from "ionic-angular";


@Component({
  selector: 'page-qiye',
  templateUrl: 'qiye.html',
  providers:[HttpServies]
})
export class QiyePage {
        imgsrc="";


    public AboutPage = AboutPage;
    dataJson: any = [];
    userInfo = {
        'creditcode': '',
        'companyname': '',
        'name': '',
        // 'mobile':'',
        'phone': '',
        'companyprofile': '',
        'site': '',
    }

    ionViewDidLoad() {
        console.log('ionViewDidLoad TestPage');
        this.getInfo();
    }

    constructor(public navCtrl: NavController, private http: HttpServies, public navParams: NavParams) {
    }

    /*
     * 企业认证提交方法
     *
     * */
    checkInfo() {
        var param = "creditcode=" + this.userInfo.creditcode
            + "&companyname=" + this.userInfo.companyname
            + "&name=" + this.userInfo.name
            // +"&mobile="+this.userInfo.mobile
            + "&phone=" + this.userInfo.phone
            + "&companyprofile=" + this.userInfo.companyprofile
            + "&site=" + this.userInfo.site;
        this.http.httpPost('/Home/Human/enterprise', param)
            .then(res => {//成功
                if (res && res.code != 0) {
                    console.log(res.msg);
                    this.http.showErro(res.msg);
                } else {
                    this.http.showErro(res.msg);
                }
            })
    }

    getInfo() {
        this.http.httpPost('/Home/Human/enterpris')
            .then(res => {//成功
                if (res && res.code == 1) {
                    console.log(res.msg);
                    this.dataJson = res.data;
                }
            })


    }
    onChange(event){
        var that=this;
        var files= event.target.files,file;
        if (files && files.length>0){
            file=files[0];
            var fileReader =new FileReader();
            fileReader.onload = function (e){
                console.log(e)
                var content =e.target.result;
                that.imgsrc=content;
            };
            fileReader.readAsDataURL(file);
        }
    }

 }


